|
|
|
|
|
|
|
The GetDriveType Function |
|
|
|
|
|
|
|
|
If youre writing an application that pulls some of its data from a CD-ROM drive, you can ask the user to fill in the drive letter of the CD-ROM or you can potentially retrieve that information yourself using the GetDriveType() function. Of course, if the user has more than one CD-ROM drive, you have to ask which one contains the CD-ROM youre looking for. Alternatively, you could just go look for a certain file on each of the CD-ROM drives until you find the right one. |
|
|
|
|
|
|
|
|
The GetDriveType() function returns a long value you use to compare against one of five constants to determine the type of the disk drive. Table 28.2 lists the constants and what each one means. |
|
|
|
|
| Table 28.2 Drive Type Constants. | | Constant | Description | | DRIVE_REMOVABLE | The disk is removable media, such as a floppy disk drive. | | DRIVE_FIXED | The disk is a hard disk on the machine. | | DRIVE_NETWORK | The disk is a network or remote drive. | | DRIVE_CD_ROM | The disk is a CD-ROM. | | DRIVE_UNKNOWN | The disk type cannot be determined or is not present. |
|
|
|
|
|
|
Examples Filename: ApiDrive.frm |
|
|
|
|
|
|
|
|
In the sample form shown in Figure 28.7, a combo box is loaded with the letters A through Z. When you select one of the letters from the combo box, the Click event calls the GetDriveType() function to determine which type of disk drive the letter represents. Heres the code: |
|
|
|
 |
|
|
|
|
Private Sub cboDrive_Click()
Dim lngType As Long
' Call the GetDriveType function
' to Retrieve the drive type lngType = GetDriveType(cboDrive.Text & ":\") Select Case lngType
Case DRIVE_REMOVABLE
txtDriveType = "Drive is Removable Media" |
|
|
|
|
|